package HoneWork1;

public class Student {
    private String name;
    private String sex;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;

    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex)throws SexException {
        if (sex.equals("男") || sex.equals("女")) {
            this.sex = sex;
        } else {
            throw new SexException("性别只能为男或女");
        }
    }
    public int getAge() {
        return age;
    }

    public void setAge(int age) throws AgeException {
        if (age >= 15 && age <= 50) {
            this.age = age;
        }else {
            throw new AgeException("年龄必须大于14或者小与51");
        }
    }
    public Student() {
    }

}
